<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>推广设置信息列表</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	 $(document).ready(function() {
		$("#qingkong").click(function(){
			$("#id").val("");
			$("#gname").val("");
			$("#searchForm").submit();
		});
		}); 

		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		//全选与全不选
		   function ckAll(Obj)
		  {
		  var collid = document.getElementById("ckAll");
		  var coll = document.getElementsByName("check");
		  if (collid.checked){
		     for(var i = 0; i < coll.length; i++)
		       coll[i].checked = true;
		  }else{
		     for(var i = 0; i < coll.length; i++)
		       coll[i].checked = false;
		  }
		  }
		//批量删除
		/* 	function deleteAll(){
			
			  obj = document.getElementsByName("check");
			    checkval = [];
			    for(k in obj){
			        if(obj[k].checked)
			        	//获取选中checkbox的值
			            checkval.push(obj[k].value);
			        }
			    $("#searchForm").attr("action","${ctx}/tuiguang/tuiguang/deleteAll?checkval="+checkval);  
				$("#searchForm").submit();
			 
		}  */
		//实现批量刪除的页面隐藏功能
		 /**	
  	$(function(){  
		    $("input[type='button']").click(function() {
		        $("input[name='check']:checked").each(function() { // 遍历选中的checkbox
		            n = $(this).parents("tr").index();  // 获取checkbox所在行的顺序
		            $("table#contentTable").find("tr:eq("+n+")").remove();
		        });
		    });
		});*/
		//批量删除，如若没有选择，提示请选中信息
		$(function(){
		    $('#btn').click(function(){
		        if($('input[name="check"]').prop("checked"))
		        {
		        	  obj = document.getElementsByName("check");
					    checkval = [];
					    for(k in obj){
					        if(obj[k].checked)
					        	//获取选中checkbox的值
					            checkval.push(obj[k].value);
					        }
					    $("#searchForm").attr("action","${ctx}/tuiguang/tuiguang/deleteAll?checkval="+checkval);  
						$("#searchForm").submit();
		        }
		        else
		            alert('请选中要删除的信息');
		    });
		})
		//导出数据和批量导出数据
		$(document).ready(function() {
			$("#btnExport").click(function(){
				 obj = document.getElementsByName("check");
				    checkval = [];
				    for(k in obj){
				        if(obj[k].checked)
				        	//获取选中checkbox的值
				            checkval.push(obj[k].value);
				        }
				top.$.jBox.confirm("确认要导出用户数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/tuiguang/tuiguang/export?checkval="+checkval);
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
				
			});
			
			//导入数据
			$("#btnImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
		});
		
		
		
	</script>
</head>
<body>
     <div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/tuiguang/tuiguang/import" method="post" enctype="multipart/form-data"
			class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="导  入  "/>
			<a href="${ctx}/tuiguang/tuiguang/import/template">下载模板</a>
		</form>
	</div>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/tuiguang/tuiguang/">推广设置信息列表</a></li>
		<shiro:hasPermission name="tuiguang:tuiguang:edit"><li>
		<a href="${ctx}/tuiguang/tuiguang/form">推广设置添加</a></li></shiro:hasPermission>
	</ul>
	
	<div><form id="as"></form></div>
	<form:form id="searchForm" modelAttribute="tuiguang" action="${ctx}/tuiguang/tuiguang/" method="post" class="breadcrumb form-search">
			<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<label>编号</label>
		<input id="id" name="id" type="text" value="${tuiguang.id}" class="input-small"/>
		<label>名称</label>
		<input id="gname" name="gname" type="text" value="${tuiguang.gname}" class="input-small"/>
		   &nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>&nbsp;
	   <input id="qingkong" class="btn btn-primary" type="button" value="清空"/>
		    <br>
			   <a href="${ctx}/tuiguang/tuiguang/form"><input type="button" value="添加"></a>
			  <!-- <a href="${ctx}/tuiguang/tuiguang/form?id=${tuiguang.id}"><input type="button" value="修改"></a> -->
			   <input type="button"  id="btn" onclick="deleteAll()" value="批量刪除">
			   <!--  <a href="${ctx}/tuiguang/tuiguang/form"><input type="button" value="審核"></a>-->
			    <input id="btnExport" class="btn btn-primary" type="button" value="导出"/>
				<input id="btnImport" class="btn btn-primary" type="button" value="导入"/>
				
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr> 
			    <th><input type="checkbox" id="ckAll" onclick="ckAll()">全选/全不选</th>
				<th>推广设置ID</th>
				<th>名称</th>
				<th>优惠券ID</th>
				<th>次数</th>
				<th>佣金</th>
				<th>开始日期</th>
				<th>结束日期</th>
				<th>地址</th>
				<th>链接</th>
				<th>规则</th>
				<th>状态</th>
				<th>备注</th>
				<th>创建人</th>
				<th>创建时间</th>
				<th class="sort-column finaltime">最后修改时间</th>
				<shiro:hasPermission name="tuiguang:tuiguang:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="tuiguang">
			<tr class="tbody odd">
			     <td>
			       <label>
					<input type="checkbox" name="check" value="${tuiguang.id }">
				  </label>
				</td>
				<td><a href="${ctx}/tuiguang/tuiguang/form?id=${tuiguang.id}">${tuiguang.id}
				    </a>
				</td>
				<td>
					${tuiguang.gname}
				</td>
				<td>
					${tuiguang.gid}
				</td>
				<td>
					${tuiguang.count}
				</td>
				<td>
					${tuiguang.price}
				</td>
				<td>
					<fmt:formatDate value="${tuiguang.beginindate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${tuiguang.endindate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					${tuiguang.url}
				</td>
				<td>
					${tuiguang.link}
				</td>
				<td>
					${tuiguang.rule}
				</td>
				<td>
					${tuiguang.state}
				</td>
				<td>
					${tuiguang.remarks}
				</td>
				<td>
					${tuiguang.createuser}
				</td>
				<td>
					<fmt:formatDate value="${tuiguang.createtime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<td>
					<fmt:formatDate value="${tuiguang.finaltime}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
				<shiro:hasPermission name="tuiguang:tuiguang:edit"><td>
    				<a href="${ctx}/tuiguang/tuiguang/form?id=${tuiguang.id}">修改</a>
					<a href="${ctx}/tuiguang/tuiguang/delete?id=${tuiguang.id}" onclick="return confirmx('确认要删除该保存推广设置吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>